<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
<meta name="keywords" content="爽客网旅游，贵阳旅游，旅游" />
<meta name="description" content="爽客网旅游，贵阳旅游，旅游" />
<title>注册 - 爽客网 </title>
<link href="/css/phone/reset.css" type="text/css" rel="stylesheet" />
<link href="/css/phone/lr.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/phone/jquery.ying.js"></script>
<script type="text/javascript" src="/js/base.js"></script>
</head>

<body>
	<form action="wapreg.htm" method="post" id="member_form">
		<div class="w320 wrap">
	    	<div class="mg_s2">
	        	<div class="com_box reg_box">
	            	<div class="left"></div>
	                <div class="content">
	                	<ul class="lr_det">
	                    	<li>
	                        	<label>邮&nbsp;&nbsp;箱</label><input type="text" value="请填写您的常用Email地址" class="def" id="email" name="email" />
	                        </li>
	                        <li>
	                        	<label>用户名</label><input type="text" value="请输入用户名" class="def" name="nickname" id="nickname" />
	                        </li>
	                        <li>
	                        	<label>设置密码</label><input type="password" value="" class="def psd" name="password" id="password" />
	                        </li>
	                        <li>
	                        	<label>确认密码</label><input type="password" value="" class="def psd" name="confirmpass" id="confirmpass" />
	                        </li>
	                    </ul>
	                </div>
	                <div class="right"></div>
	            </div>
	            
	            <a href="javascript:;" id="reg_button" class="def_link mb25">
	            	<i class="left"></i>
	                <span>立&nbsp;即&nbsp;注&nbsp;册</span>
	                <i class="right"></i>
	            </a>
	            
	
	      </div>
	    </div>
    </form>
    <script type="text/javascript">
    	
    	function emailFocus(){
    		var email = document.getElementById("email");
    		if(email.value == '请填写您的常用Email地址'){
    			email.value="";
    		//	email.focus();
    			COOL.hideLoad();
    			return false;
    		}
    		return true;
    	}
    	
    	function checkEmail(){
    		var ret = true;
    		var email = $("#email");
    		if(email.val() == null || email.val() == ''){
    			alert("请输入邮箱地址");
    		//	email.focus();
    			COOL.hideLoad();
    			return false;
    		}
    		if(!isEmail(email.val())){
    			alert("请输入正确的邮箱地址");
    		//	email.focus();
    			COOL.hideLoad();
    			return false;
    		}
    		
    		$.ajax({
				type: "post",
				url: "checkEmail.htm",
				async: false,
				data:{email:email.val()},
				success: function(data, textStatus){
					if(data=='false'){
    					alert("该邮箱已被注册，请输入其他邮箱");
    			//		email.focus();
    					ret = false;
    					COOL.hideLoad();
    				}else{
    					ret = true;
    				}
				
				},
				
				error: function(){
				
				//请求出错处理
				}
			});
    		return ret;
    		
    	}
    	
    	function nicknameFocus(){
    		var nickname = document.getElementById("nickname");
    		if(nickname.value == '请输入用户名'){
    			nickname.value="";
    		//	nickname.focus();
    			COOL.hideLoad();
    			return false;
    		}
    		return true;
    	}
    	
    	function checkNickname(){
    		var ret = true;
    		var nickname = $("#nickname");
    		if(nickname.val() == null || nickname.val() == ''){
    			alert("请输入用户名");
    	//		nickname.focus();
    			COOL.hideLoad();
    			return false;
    		}
    		$.ajax({
				type: "post",
				url: "checkNickname.htm",
				async: false,
				data:{nickname:nickname.val()},
				success: function(data, textStatus){
					if(data=='false'){
    					alert("该用户名已存在，请输入其他用户名");
    	//				nickname.focus();
    					COOL.hideLoad();
    					ret = false;
    				}else{
    					ret = true;
    				}
				
				},
				
				error: function(){
				
				//请求出错处理
				}
			});
    		return ret;
    	}
    
    	function passwordFocus(){
    		var password = document.getElementById("password");
    		if(password.value == '6-16个字符'){
    			password.value="";
    			COOL.hideLoad();
    			return false;
    		}
    		return true;
    	}
    	
    	function checkPassword(){
    		var password = $("#password");
    		if(password.val() == null || password.val() == ''){
    			alert("请输入密码");
    		//	password.focus();
    			COOL.hideLoad();
    			return false;
    		}
    		if(password.val().length < 6 || password.val().length > 16){
    			alert("密码为6-16个字符");
    	//		password.focus();
    			COOL.hideLoad();
    			return false; 
    		}
    		return true;
    	}
    	
    	function confirmpassFocus(){
    		var confirmPass = $("#confirmpass");
			if(confirmPass.val()=="请再次输入密码"){
				confirmPass.val("");
			}
    	}
    	
    	function checkConfirmPass(){
    		var confirmPass = $("#confirmpass");
    		var password = $("#password");
    		if(confirmPass.val() != password.val()){
    			if(password.val()!="请再次输入密码" && password.val()!=""){
    				alert("两次输入密码不一致");
	    		//	confirmPass.focus();
	    			COOL.hideLoad();
	    			return false; 
    			}
    		}
    		return true;
    	}
    	
    	
    	function isEmail(strEmail) {
			return (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
		}
    	
    	$(function(){
    		$("#reg_button").click(function(){
    			if(emailFocus() && checkEmail() && nicknameFocus() && checkNickname() && checkPassword() && checkConfirmPass()){
    				$("#member_form").submit();
    			}
    		});
    	});
    </script>
</body>
</html>
